package com.baixun.gascommon.config;

import com.baixun.gascommon.utils.HttpInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;
@Configuration
public class WebHttpConfig implements WebMvcConfigurer {
    @Autowired
    public HttpInterceptor httpInterceptor;


    //添加消息转换器
    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(new MappingJackson2HttpMessageConverter()); // JSON 处理
    }

//    //添加配置好的拦截器
//    public void addInterceptors(InterceptorRegistry registry){
//        registry.addInterceptor(httpInterceptor)
//                .addPathPatterns("/**").excludePathPatterns("/user/login");
//    }

}
